// 生成器
// 生成器能像迭代一样返回一个迭代对象
// 将function分块
function* test() {
    console.log(1)
    const v1 = yield 1;
    console.log(v1)
    const v2 = yield 2;
    console.log(v2)
    const v3 = yield 3;
}
// 首先生成一个迭代器
let iter4 = test()
console.log("iter", iter4)
try{
    const err = iter4.throw(123)
}catch(err){
    console.log(err)
    console.log("err i", iter4)
}
iter4.next()
console.log('last', iter4)
// throw(123)
// console.log("iter --- err", iter4)
// console.log("err", err)
/*console.log(iter4.next("one"))
 console.log(iter4.next("two"))
console.log(iter4.next("three"))
console.log(iter4.next("four")) */

